<?php
require 'TVB/pms/pdes/common/bootstrap.php';


if(empty($_REQUEST['q']))
{
	exit('[]');
}

if(empty($_REQUEST['tag_type'])){
	$type = 1;
}else{
	$type = (int) $_REQUEST['tag_type'];
}

if(empty($_REQUEST['type'])){
	$name = "name";
}else{
	$name = $_REQUEST['type'];
}

$tag_sql    = 'select id,system_label as name from tag where system_label like :q and tag_type_id=:type';

$param[':q']    = '%'.trim($_REQUEST['q']).'%';
$param[':type'] = $type;

$rs = array();
$rs = Model::selectBySql($tag_sql,$param);

$num = count($rs);

for($i=0; $i<$num; $i++)
{
	$rs[$i]['type'] = $name;
}

exit(json_encode($rs));
?>
